package other;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;

public class Sort {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Sort s = new Sort();
		s.sort(args[0]);
		
	}

	private void sort(String file) {
		ArrayList<String> list = new ArrayList<String>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(file + "+1"));
			String line;
			while((line = br.readLine()) != null){
				list.add(line);
				
			}
		
			br.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		Collections.sort(list, new MyComparator());
		
		
		try {
			PrintWriter pw = new PrintWriter(file + "+2");
			
			for(String s: list){
				String[] str = s.split(" ");
				if(!str[str.length-1].equals("0.0"))
					pw.println(s);
				
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}

}
